package com.aop;

import org.aspectj.lang.JoinPoint;
import org.aspectj.lang.ProceedingJoinPoint;
import org.aspectj.lang.annotation.*;

@Aspect
public class AnnoAdvice {
    // 切点
    @Pointcut("execution(* com.dao.impl.UserDaoImpl.*(..))")
    public void pointcut(){

    }
    @Before("pointcut()")
    public void before(JoinPoint joinPoint){
        System.out.println("这是前置通知！");
        System.out.println("目标类是：" + joinPoint.getSignature().getName());
        System.out.println(",被织入增强处理的目标方法为："+joinPoint.getSignature().getName());
    }
    @AfterReturning("pointcut()")
    public void afterReturning(JoinPoint joinPoint){
        System.out.println("这是返回通知！");
        System.out.println(",被织入增强处理的目标方法为："+joinPoint.getSignature().getName());
}
    @Around("pointcut()")
    public Object around(ProceedingJoinPoint Point) throws Throwable {
        System.out.println("这是环绕通知！");
        Object result = Point.proceed();
        System.out.println("返回值是：" + result);
        return result;
    }

    @AfterThrowing("pointcut()")
    public void afterThrowing(JoinPoint joinPoint){
        System.out.println("这是异常通知！");
        System.out.println(",被织入增强处理的目标方法为："+joinPoint.getSignature().getName());
    }
}
